home *** CD-ROM | disk | FTP | other *** search
/ PowerQuest 2002 / PowerQuest 2002.iso / POWERQUEST / PQ ControlCenter ST v2.04a for DeployCenter / CCST / data1.cab / HTML_Common / PQCCST / 040C / tree1.js < prev    next >
Encoding:
Text File  |  2001-12-05  |  11.6 KB  |  463 lines

  1. function Folder(folderDescription, hreference, image) //constructor 
  2.   //constant data 
  3.   this.desc = folderDescription 
  4.   this.hreference = hreference 
  5.   this.id = -1   
  6.   this.navObj = 0  
  7.   this.iconImg = 0  
  8.   this.nodeImg = 0  
  9.   this.isLastNode = 0 
  10.  
  11.    this.txt=0;
  12.    
  13.   //dynamic data 
  14.   this.isOpen = true 
  15. //this.iconSrc = "../../PQHTML/PQCCST/IMAGES/ftv2folderopen.gif"
  16.   this.iconSrc = image
  17.   this.children = new Array 
  18.   this.nChildren = 0 
  19.  
  20.   //methods 
  21.   this.initialize = initializeFolder 
  22.   this.setState = setStateFolder 
  23.   this.addChild = addChild 
  24.   this.createIndex = createEntryIndex 
  25.   this.hide = hideFolder 
  26.   this.display = display 
  27.   this.renderOb = drawFolder 
  28.   this.totalHeight = totalHeight 
  29.   this.subEntries = folderSubEntries 
  30.   this.outputLink = outputFolderLink 
  31.  
  32. function setStateFolder(isOpen) 
  33.   var subEntries 
  34.   var totalHeight 
  35.   var fIt = 0 
  36.   var i=0 
  37.  
  38.   if (isOpen == this.isOpen) 
  39.     return 
  40.  
  41.   if (browserVersion == 2)  
  42.   { 
  43.     totalHeight = 0 
  44.     for (i=0; i < this.nChildren; i++) 
  45.       totalHeight = totalHeight + this.children[i].navObj.clip.height 
  46.       subEntries = this.subEntries() 
  47.     if (this.isOpen) 
  48.       totalHeight = 0 - totalHeight 
  49.     for (fIt = this.id + subEntries + 1; fIt < nEntries; fIt++) 
  50.       indexOfEntries[fIt].navObj.moveBy(0, totalHeight) 
  51.   }  
  52.   this.isOpen = isOpen 
  53.   propagateChangesInState(this) 
  54.  
  55. function propagateChangesInState(folder) 
  56. {   
  57.   var i=0 
  58.  
  59.   if (folder.isOpen) 
  60.   { 
  61.     if (folder.nodeImg) 
  62.       if (folder.isLastNode) 
  63.         folder.nodeImg.src = "../../PQHTML/PQCCST/IMAGES/tree_cont.gif" 
  64.       else 
  65.       folder.nodeImg.src = "../../PQHTML/PQCCST/IMAGES/tree_cont.gif" 
  66. //my changes
  67. //    folder.iconImg.src = "../../PQHTML/PQCCST/IMAGES/ftv2folderopen.gif" 
  68.     folder.iconImg.src = folder.iconSrc
  69.     for (i=0; i<folder.nChildren; i++) 
  70.       folder.children[i].display() 
  71.   } 
  72.   else 
  73.   { 
  74.     if (folder.nodeImg) 
  75.       if (folder.isLastNode) 
  76.         folder.nodeImg.src = "../../PQHTML/PQCCST/IMAGES/tree_exp.gif" 
  77.       else 
  78.       folder.nodeImg.src = "../../PQHTML/PQCCST/IMAGES/tree_exp.gif" 
  79. //my changes      
  80. //    folder.iconImg.src = "../../PQHTML/PQCCST/IMAGES/ftv2folderclosed.gif" 
  81.     folder.iconImg.src = folder.iconSrc
  82.     for (i=0; i<folder.nChildren; i++) 
  83.       folder.children[i].hide() 
  84.   }  
  85.  
  86. function hideFolder() 
  87.   if (browserVersion == 1) { 
  88.     if (this.navObj.style.display == "none") 
  89.       return 
  90.     this.navObj.style.display = "none" 
  91.   } else { 
  92.     if (this.navObj.visibility == "hiden") 
  93.       return 
  94.     this.navObj.visibility = "hiden" 
  95.   } 
  96.    
  97.   this.setState(0) 
  98.  
  99. function initializeFolder(level, lastNode, leftSide) 
  100. var j=0 
  101. var i=0 
  102. var numberOfFolders 
  103. var numberOfDocs 
  104. var nc 
  105.       
  106.   nc = this.nChildren 
  107.    
  108.   this.createIndex() 
  109.  
  110.   var auxEv = "" 
  111.  
  112.   if (level>0) 
  113.     if (lastNode) //the last 'brother' in the children array 
  114.     { 
  115.       this.renderOb(leftSide + auxEv + "<img name='nodeIcon" + this.id + "' src='../../PQHTML/PQCCST/IMAGES/tree_cont.gif' width=8 height=8 border=0 onClick='clickOnNode("+this.id+")'>") 
  116.       leftSide = leftSide + "<img src='../../PQHTML/PQCCST/IMAGES/bar_blue.gif' width=16 height=22>"  
  117.       this.isLastNode = 1 
  118.     } 
  119.     else 
  120.     { 
  121.       this.renderOb(leftSide + auxEv + "<img name='nodeIcon" + this.id + "' src='../../PQHTML/PQCCST/IMAGES/tree_cont.gif' width=8 height=9 border=0 onClick='clickOnNode("+this.id+")'>") 
  122.       leftSide = leftSide + "<img src='../../PQHTML/PQCCST/IMAGES/bar_blue.gif' width=16 height=22>" 
  123.       this.isLastNode = 0 
  124.     } 
  125.   else 
  126.     this.renderOb("") 
  127.    
  128.   if (nc > 0) 
  129.   { 
  130.     level = level + 1 
  131.     for (i=0 ; i < this.nChildren; i++)  
  132.     { 
  133.       if (i == this.nChildren-1) 
  134.         this.children[i].initialize(level, 1, leftSide) 
  135.       else 
  136.         this.children[i].initialize(level, 0, leftSide) 
  137.       } 
  138.   } 
  139.  
  140. function drawFolder(leftSide) 
  141.   if (browserVersion == 2) { 
  142.     if (!doc.yPos) 
  143.       doc.yPos=8 
  144.     doc.write("<layer id='folder" + this.id + "' top=" + doc.yPos + " visibility=hiden>") 
  145.   } 
  146.    
  147.   doc.write("<table ") 
  148.   if (browserVersion == 1) 
  149.     doc.write(" id='folder" + this.id + "' style='position:block;' ") 
  150.   doc.write(" border=0 cellspacing=0 cellpadding=0>") 
  151.   doc.write("<tr><td>") 
  152.   doc.write(leftSide) 
  153.   this.txt=0
  154.   this.outputLink() 
  155.   doc.write("<img name='folderIcon" + this.id + "' ") 
  156.   doc.write("src='" + this.iconSrc+"' border=0 onClick='clickOnFolder("+this.id+")'>") 
  157.   doc.write("</td><td valign=middle nowrap>") 
  158.   if (USETEXTLINKS) 
  159.   { 
  160.     this.txt=1
  161.     this.outputLink() 
  162.     doc.write(this.desc + "</a>") 
  163.   } 
  164.   else 
  165.     doc.write(this.desc) 
  166.   doc.write("</td>")  
  167.   doc.write("</table>") 
  168.    
  169.   if (browserVersion == 2) { 
  170.     doc.write("</layer>") 
  171.   } 
  172.  
  173.   if (browserVersion == 1) { 
  174.     this.navObj = doc.all["folder"+this.id] 
  175.     this.iconImg = doc.all["folderIcon"+this.id] 
  176.     this.nodeImg = doc.all["nodeIcon"+this.id] 
  177.   } else if (browserVersion == 2) { 
  178.     this.navObj = doc.layers["folder"+this.id] 
  179.     this.iconImg = this.navObj.document.images["folderIcon"+this.id] 
  180.     this.nodeImg = this.navObj.document.images["nodeIcon"+this.id] 
  181.     doc.yPos=doc.yPos+this.navObj.clip.height 
  182.   } 
  183.  
  184. function outputFolderLink() 
  185.   if (this.hreference) 
  186.   { 
  187.     if(this.txt==1)
  188.     { 
  189.       doc.write("<a href='" + this.hreference + "' TARGET=\"mainFrame\" ") 
  190.       if (browserVersion > 0) 
  191.         doc.write("onClick='javascript:clickOnFolder("+this.id+")'") 
  192.       doc.write(">") 
  193.     }
  194.   } 
  195.   else 
  196.     doc.write("<a>") 
  197.  
  198. function addChild(childNode) 
  199.   this.children[this.nChildren] = childNode 
  200.   this.nChildren++ 
  201.   return childNode 
  202.  
  203. function folderSubEntries() 
  204.   var i = 0 
  205.   var se = this.nChildren 
  206.  
  207.   for (i=0; i < this.nChildren; i++){ 
  208.     if (this.children[i].children) //is a folder 
  209.       se = se + this.children[i].subEntries() 
  210.   } 
  211.  
  212.   return se 
  213.  
  214.  
  215. // Definition of class Item (a document or link inside a Folder) 
  216. // ************************************************************* 
  217.  
  218. function Item(itemDescription, itemLink,image)  // Constructor 
  219.   // constant data 
  220.   this.desc = itemDescription 
  221.   this.link = itemLink 
  222.   this.id = -1 //initialized in initalize() 
  223.   this.navObj = 0 //initialized in render() 
  224.     this.iconImg = 0 //initialized in render()
  225. //  this.iconSrc = "../../PQHTML/PQCCST/IMAGES/ftv2doc.gif" 
  226.     this.iconSrc = image
  227.  
  228.   // methods 
  229.   this.initialize = initializeItem 
  230.   this.createIndex = createEntryIndex 
  231.   this.hide = hideItem 
  232.   this.display = display 
  233.   this.renderOb = drawItem 
  234.   this.totalHeight = totalHeight 
  235.  
  236. function hideItem() 
  237.   if (browserVersion == 1) { 
  238.     if (this.navObj.style.display == "none") 
  239.       return 
  240.     this.navObj.style.display = "none" 
  241.   } else { 
  242.     if (this.navObj.visibility == "hiden") 
  243.       return 
  244.     this.navObj.visibility = "hiden" 
  245.   }     
  246.  
  247. function initializeItem(level, lastNode, leftSide) 
  248. {  
  249.   this.createIndex() 
  250.  
  251.   if (level>0) 
  252.     if (lastNode) //the last 'brother' in the children array 
  253.     { 
  254.       this.renderOb(leftSide + "<img src='../../PQHTML/PQCCST/IMAGES/bar_blue.gif' width=16 height=22>") 
  255.       leftSide = leftSide + "<img src='../../PQHTML/PQCCST/IMAGES/bar_blue.gif' width=16 height=22>"  
  256.     } 
  257.     else 
  258.     { 
  259.       this.renderOb(leftSide + "<img src='../../PQHTML/PQCCST/IMAGES/bar_blue.gif' width=16 height=22>") 
  260.       leftSide = leftSide + "<img src='../../PQHTML/PQCCST/IMAGES/bar_blue.gif' width=16 height=22>" 
  261.     } 
  262.   else 
  263.     this.renderOb("")   
  264.  
  265. function drawItem(leftSide) 
  266.   if (browserVersion == 2) 
  267.     doc.write("<layer id='item" + this.id + "' top=" + doc.yPos + " visibility=hiden>") 
  268.      
  269.   doc.write("<table ") 
  270.   if (browserVersion == 1) 
  271.     doc.write(" id='item" + this.id + "' style='position:block;' ") 
  272.   doc.write(" border=0 cellspacing=0 cellpadding=0>") 
  273.   doc.write("<tr><td>") 
  274.   doc.write(leftSide) 
  275.   doc.write("<img id='itemIcon"+this.id+"' ") 
  276.   doc.write("src='"+this.iconSrc+"' border=0>") 
  277.   doc.write("</td><td valign=middle nowrap>") 
  278.   if (USETEXTLINKS) 
  279.     doc.write("<a href=" + this.link + ">" + this.desc + "</a>") 
  280.   else 
  281.     doc.write(this.desc) 
  282.   doc.write("</table>") 
  283.    
  284.   if (browserVersion == 2) 
  285.     doc.write("</layer>") 
  286.  
  287.   if (browserVersion == 1) { 
  288.     this.navObj = doc.all["item"+this.id] 
  289.     this.iconImg = doc.all["itemIcon"+this.id] 
  290.   } else if (browserVersion == 2) { 
  291.     this.navObj = doc.layers["item"+this.id] 
  292.     this.iconImg = this.navObj.document.images["itemIcon"+this.id] 
  293.     doc.yPos=doc.yPos+this.navObj.clip.height 
  294.   } 
  295.  
  296.  
  297. // Methods common to both objects (pseudo-inheritance) 
  298. // ******************************************************** 
  299.  
  300. function display() 
  301.   if (browserVersion == 1) 
  302.     this.navObj.style.display = "block" 
  303.   else 
  304.     this.navObj.visibility = "show" 
  305.  
  306. function createEntryIndex() 
  307.   this.id = nEntries 
  308.   indexOfEntries[nEntries] = this 
  309.   nEntries++ 
  310.  
  311. // total height of subEntries open 
  312. function totalHeight() //used with browserVersion == 2 
  313.   var h = this.navObj.clip.height 
  314.   var i = 0 
  315.    
  316.   if (this.isOpen) //is a folder and _is_ open 
  317.     for (i=0 ; i < this.nChildren; i++)  
  318.       h = h + this.children[i].totalHeight() 
  319.  
  320.   return h 
  321.  
  322.  
  323. // Events 
  324. // ********************************************************* 
  325.  
  326. function clickOnFolder(folderId) 
  327.   var clicked = indexOfEntries[folderId] 
  328.  
  329.   if (!clicked.isOpen) 
  330.     clickOnNode(folderId) 
  331.  
  332.   return  
  333.  
  334.   if (clicked.isSelected) 
  335.     return 
  336.  
  337. function clickOnNode(folderId) 
  338.   var clickedFolder = 0 
  339.   var state = 0 
  340.  
  341.   clickedFolder = indexOfEntries[folderId] 
  342.   state = clickedFolder.isOpen 
  343.  
  344.   clickedFolder.setState(!state) //open<->close  
  345.  
  346. function initializeDocument(treetype) 
  347.   if (doc.all) 
  348.     browserVersion = 1 //IE4   
  349.   else 
  350.     if (doc.layers) 
  351.       browserVersion = 2 //NS4 
  352.     else 
  353.       browserVersion = 0 //other 
  354.  
  355.   foldersTree.initialize(0, 1, "") 
  356.   foldersTree.display()
  357.   
  358.   if (browserVersion > 0) 
  359.   { 
  360.     doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+"> </layer>") 
  361.  
  362.     if (treetype == 1)
  363.     {
  364.         // close the whole tree 
  365.         clickOnNode(1) 
  366.         // open the root folder 
  367.         clickOnNode(1) 
  368.     }
  369.     else
  370.     {
  371.         // close the whole tree 
  372.            clickOnNode(0) 
  373.            // open the root folder 
  374.         clickOnNode(0) 
  375.     } 
  376.   }
  377.  
  378. // Auxiliary Functions for Folder-Treee backward compatibility 
  379. // ********************************************************* 
  380.  
  381. function gFld(description, hreference,image) 
  382.   folder = new Folder(description, hreference,image) 
  383.   return folder 
  384.  
  385. function gLnk(target, description, linkData,image) 
  386.   fullLink = "" 
  387.  
  388.   if (target==0) 
  389.   { 
  390.     fullLink = "'"+linkData+"' target=\"mainFrame\"" 
  391.   } 
  392.   else 
  393.   { 
  394.     if (target==1) 
  395.        fullLink = "'http://"+linkData+"' target=_blank" 
  396.     else 
  397.        fullLink = "'http://"+linkData+"' target=\"mainFrame\"" 
  398.   } 
  399.  
  400.   linkItem = new Item(description, fullLink,image)
  401.   return linkItem 
  402.  
  403. function insFld(parentFolder, childFolder) 
  404.   return parentFolder.addChild(childFolder) 
  405.  
  406. function insDoc(parentFolder, document) 
  407.   parentFolder.addChild(document) 
  408.  
  409. // Global variables 
  410. // **************** 
  411.  
  412. USETEXTLINKS = 1 
  413. indexOfEntries = new Array 
  414. nEntries = 0 
  415. doc = document 
  416. browserVersion = 0 
  417. selectedFolder=0
  418.  
  419.